#ifndef BSDF_MTL
#define BSDF_MTL
#include "bsdf.h"
namespace gemren
{
	class bsdf_mtl: public bsdf
	{
		friend class material;
		refraction_s refr_ind;
		spectrum_dynamic display_refr_ind;
	protected:
		virtual err_t set_my_string(std::string& name, const std::string& value);
		virtual err_t set_my_float(std::string& name, const float value);
		int illum;
		bsdf* brdf, *btdf;
		bool refract;
	public:
		virtual void announce_properties(const std::string& prefix, property_announcer announcer);
		bsdf_mtl(): refr_ind(1.5f), display_refr_ind(1.5f), brdf(new brdf_diffuse), btdf(0), illum(1), refract(false){}
		virtual ~bsdf_mtl() { delete brdf; delete btdf; }
		virtual void bounce(random* ran, const scene* sc, intersection* i) const;
		virtual void bounce_fast(random* ran, const scene* sc, intersection* i) const;
		virtual bool is_light_transmitting(){return btdf? true: brdf->is_light_transmitting();}
		virtual bool is_directly_lighted(){ return brdf?  brdf->is_directly_lighted() : false;}
		virtual color_s throughput(const coord& incoming, const coord& outcoming, const coord& normal)const
		{	
			return brdf ? brdf->throughput(incoming, outcoming, normal) : color_s(0.0f);
		}
		virtual float pdf(const coord& incoming, const coord& outcoming, const coord& normal)
		{
			if(embree::dot(normal, outcoming)<0.0f)
				if(btdf) return btdf->pdf(incoming, outcoming, normal);
				else return 0.0f;
			return brdf? brdf->pdf(incoming, outcoming, normal) : 0.0f;
		}
		virtual bool has_btdf(){return btdf!=0;}
	};

}
#endif